﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

using System.Windows.Forms;
using DevComponents.DotNetBar;  
using System.Collections;       
using UFIDA.U8.DB;

namespace UFIDA.U8C.AnLian.NBBankSync
{
    public partial class BankAccUI : Form
    {
        private string _connectstring = Common.getConfigInfo("ConnectString");
    
        public string _Accid { get; set; }
        public BankAccUI()
        {
            // TODO: Complete member initialization
            InitializeComponent();       

        }       

        private void initData()
        {
            StringBuilder sqlAccount = new StringBuilder();
            sqlAccount.Append("select * from cust_Accconfig where accid = '" + _Accid + "'");
          
            try
            {
                ds_account = DbHelperSQL.Query(sqlAccount.ToString(), "cust_Accconfig", _connectstring); 
                
                bdsaccount.DataSource = ds_account;
                bdsaccount.DataMember = "cust_Accconfig"; 
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            } 
        }
         

        private void toolStripButton1_Click(object sender, EventArgs e)
        { 
            bdsaccount.EndEdit();

            try
            {
                SqlDataAdapter dal = new SqlDataAdapter("select * from cust_Accconfig where 1=2", _connectstring);

                SqlCommandBuilder scb = new SqlCommandBuilder(dal);
                dal.Update(ds_account, "cust_Accconfig");
                ds_account.AcceptChanges();
               
                MessageBox.Show("保存成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void BaseSetUI_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }
         

        private void dgvaccount_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
        {
            e.Row.Cells["accid"].Value = _Accid; 
        }

        private void BankAccUI_Load(object sender, EventArgs e)
        { 
            this.initData(); 
        }



    }
}
